/**
 * CopyRight © 2012 USTC SINOVATE SOFTWARE CO.LTD All Rights Reserved.
 */

package com.cmcc.zysoft.infocollection.service;

import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.cmcc.zysoft.infocollection.dao.ResourcePropertyPcDao;
import com.cmcc.zysoft.infocollection.model.Industry;
import com.cmcc.zysoft.infocollection.model.ResourceProperty;
import com.starit.common.dao.hibernate.HibernateBaseDao;
import com.starit.common.dao.service.BaseServiceImpl;

/**
 * @author 袁凤建
 * <br />邮箱: yuan.fengjian@ustcinfo.com
 * <br />描述: ResourcePropertyPcService.java
 * <br />版本: 1.0.0
 * <br />日期: 2013-8-14 下午4:15:01
 * <br />CopyRight © 2012 USTC SINOVATE SOFTWARE CO.LTD All Rights Reserved.
 */

@Service
public class ResourcePropertyPcService extends BaseServiceImpl<ResourceProperty, String> {

	@Resource
	private ResourcePropertyPcDao resourcePropertyPcDao;
	
	@Override
	public HibernateBaseDao<ResourceProperty, String> getHibernateBaseDao() {
		return this.resourcePropertyPcDao;
	}
	
	/**
	 * 根据行业ID获取资源属性分页列表信息.
	 * @param industryId 行业ID
	 * @param page
	 * @param rows
	 * @return map
	 */
	public Map<String, Object> getPropertyList(String industryId, int page, int rows) {
		return this.resourcePropertyPcDao.getPropertyList(industryId, page, rows);
	}
	
	/**
	 * 检查同一行业下资源属性名称是否已存在.
	 * @param industryId 行业ID
	 * @param propertyName 资源属性名称
	 * @param propertyId 资源属性ID
	 * @return Boolean
	 */
	public Boolean checkPropertyName(String industryId, String propertyName, String propertyId) {
		List<Map<String, Object>> list = this.resourcePropertyPcDao.checkPropertyName(industryId, propertyName, propertyId);
		if(list.isEmpty()) {
			return false;
		} else {
			return true;
		}
	}
	
	/**
	 * 检查同一行业下资源属性代码是否已存在.
	 * @param industryId 行业ID
	 * @param propertyCode 资源属性代码
	 * @param propertyId 资源属性ID
	 * @return Boolean
	 */
	public Boolean checkPropertyCode(String industryId, String propertyCode, String propertyId) {
		List<Map<String, Object>> list = this.resourcePropertyPcDao.checkPropertyCode(industryId, propertyCode, propertyId);
		if(list.isEmpty()) {
			return false;
		} else {
			return true;
		}
	}
	
	/**
	 * 根据行业信息和资源属性代码查找资源属性信息.
	 * @param industry 行业信息
	 * @param resourcePropertyEnname 资源属性代码
	 * @return ResourceProperty
	 */
	public ResourceProperty getResourceProperty(Industry industry, String resourcePropertyEnname) {
		return this.resourcePropertyPcDao.getResourceProperty(industry, resourcePropertyEnname);
	}
}